/*
 *    Copyright (c) 2018-2025, proj All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the proj developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: proj
 */
package com.ykht.proj.activity.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ykht.proj.activity.entity.CnActivityPersonShop;
import com.ykht.proj.activity.mapper.CnActivityPersonShopMapper;
import com.ykht.proj.activity.service.CnActivityPersonShopService;
import com.ykht.proj.activity.service.CnActivityShopService;
import com.ykht.proj.common.core.util.R;
import com.ykht.proj.coupon.vo.AboutShopVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 用户购买活动关联商铺表
 *
 * @author csg
 * @date 2020-12-23 11:13:32
 */
@Service
public class CnActivityPersonShopServiceImpl extends ServiceImpl<CnActivityPersonShopMapper, CnActivityPersonShop> implements CnActivityPersonShopService {
	@Resource
	private CnActivityShopService cnActivityShopService;

	@Override
	public R<IPage<AboutShopVo>> getCnActivityOrderShopPage(Page page, Long id, String longitude, String latitude) {
		List<CnActivityPersonShop> cnActivityShopList = this.list(Wrappers.lambdaQuery(CnActivityPersonShop.class).eq(CnActivityPersonShop::getOrderId, id));
		List<Long> ids = cnActivityShopList.stream().map(CnActivityPersonShop::getShopId).distinct().collect(Collectors.toList());
		return R.ok(cnActivityShopService.AboutShopVoPage(page, ids, longitude, latitude));
	}
}
